package com.baizhi.product.controller;


import com.baizhi.entity.ResultEntity;
import com.baizhi.product.entity.Category;
import com.baizhi.product.service.ICategoryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品三级分类 前端控制器
 * </p>
 *
 * @author zhangsan
 * @since 2022-03-23
 */
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private ICategoryService cs;
    //根据父类别的编号查询该类别下面的所有子类别
    @GetMapping("/selectChildrenCategory/{categoryId}")
    public ResultEntity selectChildrenCategory(@PathVariable("categoryId") Long cid){
        QueryWrapper<Category> wrapper=new QueryWrapper<>();
        wrapper.eq("parent_id",cid);
        List<Category> list = cs.list(wrapper);
        return ResultEntity.ok(list);
    }
}

